#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

typedef struct Student
{
    char name[10]; //名字
    long long number; //学号
    int drift; //学生排名浮动
    int totality; //成绩总和
    int C;
    int English;
    int Math;
    int average; //平均分
    int maxgrade; //历史最高分
    int MMath; //数学最高
    int MEnglish; //英语最高
    int MC; //C最高
    int dailyMath; //数学平时
    int dailyEnglish; //英语平时
    int dailyC; //C语言平时
} Student;

void fail(Sudent* student, int n,char* m)
{
	int count = 0;
	//记录数学成绩不及格的人数，学号以及姓名
	if (strcmp(m, "数学") == 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (student[i].Math < 60)
			{
				count++;
				printf("%d %s\n",student[i].number,student[i].name);
			}
		}
		printf("%d/n", count);
	}
	//记录英语成绩不及格的人数，学号以及姓名
	else if (strcmp(m, "英语") == 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (student[i].Math < 60)
			{
				count++;
				printf("%d %s\n", student[i].number, student[i].name);
			}
		}
		printf("%d/n", count);
	}
	//记录C语言成绩不及格的人数，学号以及姓名
	else
	{
		for (int i = 0; i < n; i++)
		{
			if (student[i].Math < 60)
			{
				count++;
				printf("%d %s\n", student[i].number, student[i].name);
			}
		}
		printf("%d/n", count);
	}

}

void findMAX(Student* students, int n, char* m)
{
    int max = 0, index = 0; // 初始化最高分和索引
    // 查找数学成绩最高
    if (strcmp(m, "数学") == 0)
    {
        max = students[0].Math;
        for (int i = 1; i < n; i++)
        {
            if (students[i].Math > max)
            {
                max = students[i].Math;
                index = i;
            }
        }
        printf("数学最高分：%d 学号：%lld 姓名：%s\n", students[index].Math, students[index].number, students[index].name);
    }
    // 查找C语言成绩最高
    else if (strcmp(m, "C") == 0)
    {
        max = students[0].C;
        for (int i = 1; i < n; i++)
        {
            if (students[i].C > max)
            {
                max = students[i].C;
                index = i;
            }
        }
        printf("C语言最高分：%d 学号：%lld 姓名：%s\n", students[index].C, students[index].number, students[index].name);
    }
    // 查找英语成绩最高
    else if (strcmp(m, "英语") == 0)
    {
        max = students[0].English;
        for (int i = 1; i < n; i++)
        {
            if (students[i].English > max)
            {
                max = students[i].English;
                index = i;
            }
        }
        printf("英语最高分：%d 学号：%lld 姓名：%s\n", students[index].English, students[index].number, students[index].name);
    }
    else
    {
        printf("输入的科目名称不正确，请输入 '数学'、'C' 或 '英语'\n");
    }
}

int main()
{
    int n, i;
    scanf("%d", &n);
    Student students[100];

    for (i = 0; i < n; i++)
    {
        scanf("%s", students[i].name);
        scanf("%lld", &students[i].number);
        scanf("%d", &students[i].C);
        scanf("%d", &students[i].Math);
        scanf("%d", &students[i].English);
    }

    char subject[10];
    printf("请输入要查询的科目名称（数学、C、英语）：");
    scanf("%s", subject);

    findMAX(students, n, subject);
    fall(student,n,subject);

    return 0;
}